package com.aaa.charge.service.impl;

import com.aaa.charge.dao.BackfeeDao;
import com.aaa.charge.service.BackfeeService;
import com.aaa.charge.vo.OrderBackfeeVo;
import com.aaa.entity.OrderBackfee;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;

/**
 * @author pzs
 * @date 2023/3/24 11:23
 * @description OrderChargeService
 */
@Service
public class BackfeeServiceImpl implements BackfeeService {
    @Resource
    private BackfeeDao orderBackfeeDao;

    @Override
    public Result<IPage<OrderBackfee>> findAllBackfee(Integer currentPage, Integer pageSize, OrderBackfeeVo orderBackfeeVo) {
        IPage<OrderBackfee> page=new Page<>(currentPage,pageSize);
        QueryWrapper<OrderBackfee> wrapper=new QueryWrapper<>();
        if(StringUtils.hasText(orderBackfeeVo.getPatientName())){
            wrapper.like("patient_name",orderBackfeeVo.getPatientName());
        }
        if(StringUtils.hasText(orderBackfeeVo.getRegId())){
            wrapper.eq("reg_id",orderBackfeeVo.getRegId());
        }

        IPage<OrderBackfee> page1=orderBackfeeDao.selectPage(page,wrapper);

        return new Result<>(page1);
    }
}
